import { ObjCreate } from "../common/ObjCreate";
import { ImagesConst } from "../../resource/ImagesConst";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { Cache } from "../../cache/Cache";
import { ShopTipsConfig } from "../../resource/ShopTipsConfig";
type int = number;
//class ShopMallTipPanel
    
    export  class ShopMallTipPanel /* flash.display.Sprite */
    {
        constructor()
        {
            
            this.init();
            return;
        }

        public roll(arg1: Boolean): void
        {
            if (arg1) 
            {
                this.addEventListener(flash.events.Event.ENTER_FRAME, this.onEnterFrameHandler);
            }
            else 
            {
                this.removeEventListener(flash.events.Event.ENTER_FRAME, this.onEnterFrameHandler);
            }
            return;
        }

        /* internal  */init(): void
        {
            this._startBitmap = ObjCreate.createBitmap(ImagesConst.Fire, 0, -6, this);
            this._endBitmap = ObjCreate.createBitmap(ImagesConst.Fire, 0, -6, this);
            this._tipTxt = ObjCreate.createTextField("", 0, 2, 220, 20, this, GlobalStyle.textFormat2);
            this._tipTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._tipMask = new Object /* flash.display.Sprite */();
            this._tipMask.graphics.beginFill(16777215, 0);
            this._tipMask.graphics.drawRect(0, 0, 640, 30);
            this._tipMask.graphics.endFill();
            this.addChild(this._tipMask);
            this._tipTxt.mask = this._tipMask;
            return;
        }

        /* internal  */onEnterFrameHandler(arg1: Object /* flash.events.Event */): void
        {
            var loc1=0;
            var loc3=0;
            var loc2=Cache.instance.daily.serverOpenDay;
            this._tipTxtX = this._tipTxtX - 2;
            this._tipTxt.x = this._tipTxtX;
            this._startBitmap.x = this._tipTxtX - 26;
            this._endBitmap.x = this._tipTxtX + this._tipTxt.width;
            this._startBitmap.visible = this._startBitmap.x >= 0 && this._startBitmap.x <= 640;
            this._endBitmap.visible = this._endBitmap.x >= 0 && this._endBitmap.x <= 640;
            if (this._tipTxtX == -this._tipTxt.width || this._tipTxt.width == 4) 
            {
                if (loc2 <= 3) 
                {
                    loc1 = Math.round(Math.random() * ((ShopTipsConfig.instance.panicLength - 1) - 1)) + 1;
                    this._tipTxt.htmlText = ShopTipsConfig.instance.getPanicTipsByIndex(loc1);
                }
                else 
                {
                    loc3 = ShopTipsConfig.instance.maxIndex;
                    loc1 = Math.round(Math.random() * ShopTipsConfig.instance.maxIndex) + 2;
                    this._tipTxt.htmlText = ShopTipsConfig.instance.getTipsById(loc1);
                }
                this._tipTxtX = 650;
            }
            return;
        }

        /* internal */ /* var */_startBitmap: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_endBitmap: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_tipTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_tipMask: Object /* flash.display.Sprite */;

        /* internal */ /* var */_tipTxtX: int=0;
    }
